<!--<a href="#/layui/zhiweiList" class="layui-btn layui-btn-xs layui-btn-primary" style="margin: 20px 0 0 100px;">
  <i class="layui-icon">&#xe65c;</i>
</a>-->



<form action="" class="layui-form">
	<div class="layui-fluid">
		<div class="layui-card">
			<div class="layui-row">
			    <div class="layui-col-md12">
			    	<div class="layui-card-header">
			    		<h2>
			      <a href="#/layui/zhiweiList" class="layui-btn layui-btn-xs layui-btn-primary" style="margin: -0px 0 0 0;border: none;background-color: rgba(0,0,0,0);">
															  <i class="layui-icon">&#xe65c;</i>
															</a>
			      	
			      	添加职位名称</h2>
			      </div>
			      
			      
			      	
			      	<div class="layui-card-body">
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">职位名称：<span class="haveTo">*</span></div>
			      			<div class="layui-input-block">
			      				<input type="text" name="jobName" lay-verify="required" class="layui-input jobName input33">
			      			</div>
			      		</div>
			      		<div class="layui-form-item">
			      			<div class="layui-form-label">备注：</div>
			      			<div class="layui-input-block">
			      				<textarea name=""  placeholder="" class="layui-textarea job_ta input33"></textarea>
			      			</div>
			      		</div>
			      		
			      	</div>
			      	<table class="layui-table" lay-size="lg" lay-skin="nob">
					      
					      <tbody>
					      	
					      	
					      	<!--<tr>
					      		<td class="small_td">职位名称：</td>
					      		<td><input type="text" name="jobName" class="layui-input jobName input33"></td>
					      	</tr>-->
					      	<!--<tr>
					      		<td class="small_td">备注：</td>
					      		<td>
					      			<textarea name=""  placeholder="" class="layui-textarea job_ta input33"></textarea>
					      		</td>
					      	</tr>-->
					      	
						    
						  </tbody>
					      	
				      </table>
			    </div>
			    
			    <div class="layui-col-md10">
			    	<div class="addFHBtn">
						<button class="layui-btn confirm" lay-submit lay-filter="queding" type="button" >确定</button>
					</div>
			    </div>
			    
			  </div>
			</div>



		</div>
	</div>
</form>

<script type="text/javascript">
//	let jobId = document.querySelector(".jobId");
	let jobName = document.querySelector(".jobName");
	let job_ta = document.querySelector(".job_ta");
	let confirm = document.querySelector(".confirm");
	
	layui.use(['jquery', 'mockjs', 'table', 'sidebar', 'form','route'], function () {
		var $ = layui.jquery,
      layer = layui.layer,
      table = layui.table,
      sidebar = layui.sidebar,
      route = layui.route,
      params = route.params(),
      form = layui.form;
      
      let _obj = {
      	"Id": "0",
		    "Name": "",
		    "PositionImage": "",
		    "Memo": "",
		    "CreateTime": "",
		    "CreateUser": "",
		    "ModifyTime": "",
		    "ModifyUser": ""
      }
      
      if(params){
      	DBHelper.Get("Admin_Xn_Position?id="+params.id,function(data){
      		console.log(1,data)
//    		jobId.value=data.Id;
      		jobName.value=data.Name;
      		job_ta.value=data.Memo;
      		console.log("data.AreaCode",data.AreaCode)
      		_obj = data;
//    		_obj = {
//    			"Id": "",
//				    "Name": "",
//				    "PositionImage": "",
//				    "Memo": "",
//				    "CreateTime": data.CreateTime,
//				    "CreateUser": data.CreateUser,
//				    "ModifyTime": "",
//				    "ModifyUser": ""
//		    
//		  		}
      	},function(data){
      		console.log(data)
      	})
      }
      
      function _confirm (){
      	
						
//						_obj.Id = jobId.value;
						_obj.Name = jobName.value;
						_obj.Memo = job_ta.value;
						
						
					
						if(params == null) {
							 _obj.CreateTime = getNowFormatDate();
							 _obj.CreateUser = localStorage.getItem("user");
//							_obj.CreateTime = new Date();
							console.log("_obj",_obj)
							DBHelper.Post("Admin_Xn_Position", _obj, function(data) {
								console.log(data)
								let index = layer.alert("操作成功",function(){
				  				window.location.href="#/layui/zhiweiList";
				  				layer.close(index)
				  		})
							}, function(data) {
								console.log(data)
							});
						} else {
							_obj.ModifyTime = getNowFormatDate();
							_obj.ModifyUser = localStorage.getItem("user");
							console.log(params.id)
//							_obj.ModifyTime = new Date();
//							console.log(new Date())
							DBHelper.Put("Admin_Xn_Position?id=" + params.id, _obj, function(data) {
								let index = layer.alert("操作成功",function(){
				  				window.location.href="#/layui/zhiweiList";
				  				layer.close(index)
				  		})
//								window.location.href="#/layui/zhiweiList";
							}, function(data) {
								console.log(data)
							})
						}
					}
      
      
//    confirm.addEventListener("click",_confirm)
			form.on('submit(queding)',_confirm)
      
    })
	
	
	
</script>
	<style scoped>
				.small_td{
					text-align: right;
					width: 100px;
				}
      	.title{
      		/*margin-left: 30px;*/
      		margin-top: 30px;
      	}
      	.checkBtn{
      		border-radius: 5px;
      		width: 100px;
      	}
      	.listBtns{
      		display: flex;
      		justify-content: space-between;
      		width: 100%;
      	}
      	.listBtn{
      		border-radius: 5px;
      	}
      	.addFHBtn{
      		text-align: center;
      		margin-top: 20px;
      		margin-bottom: 20px;
      	}
      	.haveTo{
      		color: red;
      	}
      	.addFHBtn button{
      		display: inline-block;
      		width: 300px;
      	}
      </style>
       
      